package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {
    /**
     * 根据openId查询用户
     * @param openId
     * @return
     */
    @Select("select * from user where openid = #{openId}")
    User selectByOpenId(String openId);

    /**
     * 存储用户
     * @param user
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into  user (openid, name, create_time) values (#{openid},#{name},#{createTime})")
    void insert(User user);

    /**
     * 根据用户ID查询
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User selectById(Long userId);
}
